package com.design.pattern.composite;

import java.util.Iterator;

public class Waitress {

    MenuComponent allMenus;

    public Waitress(MenuComponent allMenus) {
        this.allMenus = allMenus;
    }

    public void printMenus() {
        allMenus.print();
    }

    public void printVegetarianMenu() {
        Iterator iterator = allMenus.createIterator();
        System.out.println("###############################");

        while (iterator.hasNext()) {
            MenuComponent menuComponent = (MenuComponent) iterator.next();
            menuComponent.print();
//            try {
//                if (menuComponent.isVegetarian()) {
//                    menuComponent.print();
//                }
//            } catch (UnsupportedOperationException e) {
//            }
        }
    }
}